package org.dromara.report.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseService;
import org.dromara.report.domain.Report;
import org.dromara.report.service.ReportServiceImpl;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页获取报表信息
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report/order")
public class ReportController extends BaseService {

  private final ReportServiceImpl reportService;

  /**
   * 首页获取订单信息
   */
  @SaCheckPermission("report:order:orderList")
  @GetMapping("/orderList")
  public TableDataInfo<Report> getOrderList(Report order) {
    return TableDataInfo.build(reportService.getOrderLine(order,List.of(order.getTypeIds())));
  }

  /**
   * 首页获取物品订单销售额信息
   */
  @SaCheckPermission("report:order:productOrderSort")
  @GetMapping("/productOrderSort")
  public TableDataInfo<Report> getProductOrderSort(Report order) {
    return TableDataInfo.build(reportService.getProductOrderSort(order,List.of(order.getTypeIds())));
  }

  /**
   * 首页获取订单消息信息
   */
  @SaCheckPermission("report:order:orderMsgList")
  @GetMapping("/orderMsgList")
  public TableDataInfo<Report> getOrderMsgList(Report order) {
    return TableDataInfo.build(reportService.getOrderMsgLine(order,List.of(order.getTypeIds())));
  }

}
